from django.contrib import admin

# Register your models here.
from django.contrib.auth.admin import UserAdmin

from ShoppingMall.models import UserInfo, Cake, Place, CakeType, CakeImg, Rotation, HotSale, Show


# Underwriter Admin model
class UserInfoAdmin(UserAdmin):
    # 这是在管理页面中想要显示的内容
    list_display = ['username', 'email', 'date_joined', 'last_login']
    # 分页
    list_per_page = 10
    # 设置 只读 的字段
    readonly_fields = ['date_joined', 'last_login']
    # 后台显示的字段
    fieldsets = [
        (None, {'fields': ['username', 'password', 'phone', 'is_vip', 'email', 'is_staff', 'is_superuser']}),
        ('用户活跃信息', {'fields': ['date_joined', 'last_login']}),
    ]


# Underwriter Cake model
class CakeAdmin(admin.ModelAdmin):
    # 需要显示的字段信息
    list_display = ('id', 'name', 'brief', 'price', 'size', 'sales_num', 'status', 'type')

    # 设置哪些字段可以点击进入编辑界面，默认是第一个字段
    list_display_links = ('id', 'name')


admin.site.register(Cake,CakeAdmin)
admin.site.register(CakeType)
admin.site.register(CakeImg)
admin.site.register(UserInfo, UserInfoAdmin)
admin.site.register(Place)
admin.site.register(Rotation)
admin.site.register(HotSale)
admin.site.register(Show)
